package org.anlu.paypallesson02.controller;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.anlu.paypallesson02.service.PayPalCheckoutService;
import org.anlu.paypallesson02.utils.RequestToMapUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;



@RestController
public class PayPalCheckoutController {
    @Autowired
    private PayPalCheckoutService payPalCheckoutService;

    @PostMapping(value = "/paypal/ipn/back")
    public String callback(HttpServletRequest request, HttpServletResponse response) {
        return payPalCheckoutService.callback(RequestToMapUtil.getParameterMap(request));
    }

}
